#include "ContinousDisplay.h"
#include "DisplayController.h"
#include "History.h"
#include <stdio.h>

#include <QPainter>

ContinousDisplay::ContinousDisplay(QWidget* parent)
	: QWidget(parent)
{
	
}

void ContinousDisplay::setController(DisplayController* pController)
{
	_pDisplayController = pController;
}

void ContinousDisplay::paintEvent(QPaintEvent*)
{
	_pDisplayController->Redraw();	
}

void ContinousDisplay::drawSignal(History* pHistory, int timeScale)
{
	QPainter painter(this);

	vector<Reading>	v = pHistory->tail(width(), timeScale);
	
	for(unsigned int i = 1; i<v.size(); i++)
	{
		painter.drawLine(QPoint(i,v[i-1].value*height()/4048+height()/2),
			 QPoint(i,v[i].value*height()/4048+height()/2));

//		painter.drawPoint(i,(v[i].value*height())/2048+height()/2);

	}
}
